-
Notifications
You must be signed in to change notification settings - Fork 226
feat: option to triggering reconciler on all events #2894
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: next
Are you sure you want to change the base?
Conversation
c4f8193
to
eeff1ed
Compare
aa171b6
to
8c44cd5
Compare
2e5e220
to
8f69a5e
Compare
0f0cca9
to
fd68244
Compare
Signed-off-by: Attila Mészáros <[email protected]>
Signed-off-by: Attila Mészáros <[email protected]>
Signed-off-by: Attila Mészáros <[email protected]>
Signed-off-by: Attila Mészáros <[email protected]>
Signed-off-by: Attila Mészáros <[email protected]>
Signed-off-by: Attila Mészáros <[email protected]>
Signed-off-by: Attila Mészáros <[email protected]>
Signed-off-by: Attila Mészáros <[email protected]>
Signed-off-by: Attila Mészáros <[email protected]>
Signed-off-by: Attila Mészáros <[email protected]>
Signed-off-by: Attila Mészáros <[email protected]>
Signed-off-by: Attila Mészáros <[email protected]>
Signed-off-by: Attila Mészáros <[email protected]>
Signed-off-by: Attila Mészáros <[email protected]>
Signed-off-by: Attila Mészáros <[email protected]>
Signed-off-by: Attila Mészáros <[email protected]>
Signed-off-by: Attila Mészáros <[email protected]>
Signed-off-by: Attila Mészáros <[email protected]>
Signed-off-by: Attila Mészáros <[email protected]>
Signed-off-by: Attila Mészáros <[email protected]>
c1f2daa
to
1765745
Compare
Signed-off-by: Attila Mészáros <[email protected]>
Signed-off-by: Attila Mészáros <[email protected]>
Signed-off-by: Attila Mészáros <[email protected]>
Signed-off-by: Attila Mészáros <[email protected]>
Signed-off-by: Attila Mészáros <[email protected]>
As mentioned in the issue, I'd rather see this supported via listeners than via yet another feature flag. |
The idea behind this is same as controllers work in go, having a separate listernet would not be an eleant solution, basically we just trigger reconiliation for all the events as in go is done by default. This way we don't need an another interface or any other construct. |
Also in the past on purpose reduced the number of those interaces, and I think that was the right choice. I'm not that happy about to much feature flags, but I see this the as the better option now, since it is closed to go; feature flags use can much easier see than a new interface. And note that this is nost just about the delete events, but all the events, for example when others have finalizers added to the custom resources, it is marked for deletion, but meanwhile updated (or just on the mar of deletion event) so acutally much harder to capture with an interface. I really think this is a better model just to have to trigger the reconciler on everthing than having separate methods. |
Following the go SDK should only been done where it makes sense. I don't think it's a particularly compelling argument for this particular design or the other flags that have been introduced lately. |
That is just a side note regarding to go, I don't see how an interface is a good alterative for that, especailly that we tried to eliminate (and did) all the interfaces for v5. But the main issues I see that, it would be even hard to scope as an interface, how would you define that? which events would trigger that interface? |
What other flags you mean? |
@metacosm I was giving more thoughs about this, but basically came to the same conclusion, regarding feature flags / interfaces. Basically this was to have all events trigger the reconiler functions gives a very good mental model, and a simplistic user interface, that "I get triggered an all events, and can check in what state the primary and secondary resources are and act upon that" Pls review the PR in depth. |
For this pls create an issue where we can separately discuss your concerns in detail. |
boolean isNextReconciliationImminent(); | ||
|
||
/** | ||
* To check if the primary resource is already deleted. This value can be true only if you turn on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be enforced in the code.
boolean isPrimaryResourceDeleted(); | ||
|
||
/** | ||
* Check this only if {@link #isPrimaryResourceDeleted()} is true. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
public static <P extends HasMetadata> P conflictRetryingPatch( | ||
KubernetesClient client, | ||
P resource, | ||
UnaryOperator<P> unaryOperator, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please provide proper javadoc for all public methods with appropriate parameter names (e.g. unaryOperator
doesn't help understand what is the purpose of this parameter).
public void onDelete(T resource, boolean b) { | ||
super.onDelete(resource, b); | ||
eventReceived(ResourceAction.DELETED, resource, null); | ||
eventReceived(ResourceAction.DELETED, resource, null, b); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use a proper parameter name instead of b
.
import io.fabric8.kubernetes.api.model.HasMetadata; | ||
import io.javaoperatorsdk.operator.processing.event.ResourceID; | ||
|
||
public class ResourceDeleteEvent extends ResourceEvent { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add documentation.
|
||
private void handleMarkedEventForResource(ResourceState state) { | ||
if (state.deleteEventPresent()) { | ||
if (state.deleteEventPresent() && !triggerOnAllEvent()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extract in a separate method, that can be reused elsewhere.
log.debug( | ||
"Resource not found in the cache, checking for delete event resource: {}", | ||
resourceID); | ||
var state = resourceStateManager.get(resourceID); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should only be done / needed if this is a delete event so the state retrieval should only be done in that case.
.filter(ResourceState::deleteEventPresent) | ||
.map(ResourceState::getLastKnownResource); | ||
if (actualResource.isEmpty()) { | ||
throw new IllegalStateException("this should not happen"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a proper message here instead.
Adds option to trigger reconciliation on all events.
Signed-off-by: Attila Mészáros [email protected]